#include <iostream>
#include <unordered_map>

using namespace std;

const int N = 2e5 + 10;
unordered_map<int, int> A;
int arr[N];


signed main() {
	int n, c;
	A.reserve(N << 1);
	scanf("%d %d", &n, &c);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", arr + i);
		A[arr[i]] ++;
	}
	int res = 0;
	for (int i = 1; i <= n; ++ i) {
		res += A[arr[i] + c];
	}
	cout << res;
	return 0;
}
